"""
线索页面添加线索用例(联系人姓名长度为1)
"""
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
import unittest
#定位器
name_locator = (By.NAME, "name")
password_locator = (By.NAME, "password")
login_locator = (By.CSS_SELECTOR, "body > div.container > div > div.span4 > div > form > fieldset > input.btn.btn-primary")
xs_link_locator =(By.LINK_TEXT,"线索")
xs_add_locator = (By.CSS_SELECTOR,"body > div.container > div.row > div:nth-child(1) > div > a")
xs_add_lxrxm_locator = (By.CSS_SELECTOR,"#contacts_name")
xs_add_sj_locator = (By.ID,"mobile")
xs_add_yx_locator = (By.ID,"email")
xs_add_bc_locator =(By.CSS_SELECTOR,"#form1 > table > tfoot > tr > td > input:nth-child(1)")
xs_add_zw_locator = (By.ID,"position")
#所需数据
name = "admin"
password = "123456"
lxrxm = "X"
sj = "13408003620"
yx = "333@qq.com"
zw = "牛xx"
#操作
#打开浏览器
driver = webdriver.Chrome()
#最大化窗口
driver.maximize_window()
#进入悟空CRM登录界面
driver.get("http://192.168.1.25/crm/")
#输入用户名
driver.find_element(*name_locator).send_keys(name)
#输入密码
driver.find_element(*password_locator).send_keys(password)
#点击确定按钮
driver.find_element(*login_locator).click()
#点击线索按钮
driver.find_element(*xs_link_locator).click()
#点击添加线索
driver.find_element(*xs_add_locator).click()
#输入联系人姓名
driver.find_element(*xs_add_lxrxm_locator).send_keys(lxrxm)
#输入职位
driver.find_element(*xs_add_zw_locator).send_keys(zw)
#输入手机号
driver.find_element(*xs_add_sj_locator).send_keys(sj)
#输入邮箱
driver.find_element(*xs_add_yx_locator).send_keys(yx)
#点击保存
driver.find_element(*xs_add_bc_locator).click()
sleep(5)
#关闭浏览器
driver.quit()
if __name__ == '__main__':
    unittest.main()

